package com.cgtong.android.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import com.blankj.utilcode.util.TimeUtils;
import com.cgtong.android.R;
import com.cgtong.android.bean.ActivityBean;
import com.cgtong.android.http.ConstantManager;
import com.cgtong.android.widget.GlideApp;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

/**
 * Created by Sky.Bing on 2017/10/18.
 */

public class MyParticipationListAdapter extends BaseQuickAdapter<ActivityBean, BaseViewHolder> {

    public MyParticipationListAdapter() {
        super(R.layout.adapter_my_participation, null);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, ActivityBean activityBean) {
        baseViewHolder.setText(R.id.part_activity_name, activityBean.getTitle());
        int activityState = activityBean.getActivityState();
        switch (activityState) {
            case 1:
                baseViewHolder.setText(R.id.part_activity_status, R.string.txt_activity_ongoing);
                break;
            case 2:
                baseViewHolder.setText(R.id.part_activity_status, R.string.txt_activity_nostart);
                break;
            case 3:
                baseViewHolder.setText(R.id.part_activity_status, R.string.txt_activity_expire);
                break;
            default:
                baseViewHolder.setText(R.id.part_activity_status, R.string.txt_activity_unknown);
                break;
        }
        if (!TextUtils.isEmpty(activityBean.getCreated_at())) {
            baseViewHolder.setText(R.id.part_activity_time, "截止时间："+TimeUtils.date2String(TimeUtils.string2Date(activityBean.getE_time(), ConstantManager.YYYY_MM_DD_FORMAT), ConstantManager.YYYY_MM_DD_FORMAT));
        }
        GlideApp.with(mContext).load(activityBean.getImg_url()).fitCenter().placeholder(R.drawable.icon_default_loading).error(R.drawable.icon_default_error)
                .into((ImageView) baseViewHolder.getView(R.id.part_activity_image));
    }
}